from copy import copy
import pygame
import UAI
class Drawable(pygame.sprite.Sprite):
    name    = "Drawable"
    movable  = 0
    collide  = 1
    width    = 20
    height   = 20
    color    = (100,100,100)
    overlaytext = ''
    
    def __init__(self, pos = (0, 0)):
        self.drawon = UAI.screen
        pygame.sprite.Sprite.__init__(self)
        self.g = pygame.sprite.RenderPlain(self)
        self.image = pygame.Surface((self.width, self.height))
        if self.color:
            self.image.fill(self.color)
        self.rect = self.image.get_rect()
        self.rect.move_ip(pos)
    
    def draw(self):
        self.g.draw(self.drawon)
        self.drawOverlayText()
    
    def setColor(self, color):
        self.color = color
        self.image.fill(self.color)
    
    def run(self):
        pass
    
    def overlayText(self, str):
        self.overlaytext = str
        
    def drawOverlayText(self):
        if self.overlaytext:
            rect = copy(self.rect)
            rect.move_ip(2,2)
            text = UAI.font10.render(self.overlaytext, 1, UAI.colors.OSDTEXT_SHADOW)
            self.drawon.blit(text, rect)
            rect.move_ip(-1,-1)
            text = UAI.font10.render(self.overlaytext, 1, UAI.colors.OSDTEXT)
            self.drawon.blit(text, rect)